Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(button -> negative): corrects interior label background color to align with parent #3078

Merged
merged 7 commits into from
Sep 17, 2024

Conversation

cdransf
Copy link
Member

@cdransf cdransf commented Sep 6, 2024

Description

  • Apples forced-color-adjust: none to align the rendered background of the child label for negative button varient with the enclosing button's background color.

How and where has this been tested?

Verified in Assistiv Labs high contrast mode-enabled Windows VM.

Validation steps

  1. Run Storybook locally (or reference the link for this PR).
  2. Navigate to Assistiv Labs and start a Windows High Contrast Mode VM (if running the branch locally, you'll need to enable the Assistiv Labs tunnel to access Storybook).
  3. Enable Windows High Contrast Mode.
  4. Navigate to the Button component in Storybook.
  5. Select the negative variant.
  6. Zoom in and verify that the there is no background (the button background should be a uniform color).

Regression testing

Validate:

  1. The documentation pages for at least two other components are still loading, including:
  • The pages render correctly, are accessible, and are responsive.
  1. If components have been modified, VRTs have been run on this branch:
  • VRTs have been run and looked at.
  • Any VRT changes have been accepted (by reviewer and/or PR author), or there are no changes.

Screenshots

Screenshot 2024-09-12 at 4 46 58 PM Screenshot 2024-09-12 at 4 46 12 PM

To-do list

  • I have read the contribution guidelines.
  • I have updated relevant storybook stories and templates.
  • I have tested these changes in Windows High Contrast mode.
  • If my change impacts other components, I have tested to make sure they don't break.
  • If my change impacts documentation, I have updated the documentation accordingly.
  • ✨ This pull request is ready to merge. ✨

Copy link

changeset-bot bot commented Sep 6, 2024

🦋 Changeset detected

Latest commit: 4dc7f9e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@spectrum-css/button Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cdransf cdransf requested a review from jawinn September 6, 2024 19:15
@cdransf cdransf self-assigned this Sep 6, 2024
@cdransf cdransf added run_vrt For use on PRs looking to kick off VRT ready-for-review labels Sep 6, 2024
Copy link
Contributor

github-actions bot commented Sep 6, 2024

🚀 Deployed on https://pr-3078--spectrum-css.netlify.app

Copy link
Contributor

github-actions bot commented Sep 6, 2024

File metrics

Summary

Total size: 4.11 MB*
Total change (Δ): ⬆ 2.90 KB (0.07%)

Table reports on changes to a package's main file. Other changes can be found in the collapsed Details section below.

Package Size Δ
button 83.96 KB ⬆ 0.99 KB

Details

button

File Head Base Δ
index-base.css 54.01 KB 53.04 KB ⬆ 0.99 KB (1.82%)
index-theme.css 30.56 KB 30.56 KB -
index-vars.css 83.96 KB 82.99 KB ⬆ 0.99 KB (1.16%)
index.css 83.96 KB 82.99 KB ⬆ 0.99 KB (1.16%)
themes/express.css 29.37 KB 29.37 KB -
themes/spectrum.css 29.43 KB 29.43 KB -
* Size determined by adding together the size of the main file for all packages in the library.
* Results are not gzipped or minified.
* An ASCII character in UTF-8 is 8 bits or 1 byte.

@cdransf cdransf force-pushed the cdransf/button-high-contrast-label-fix branch 2 times, most recently from 3df3bde to 458c8b0 Compare September 6, 2024 20:12
@cdransf cdransf requested a review from pfulton September 6, 2024 20:33
@cdransf cdransf force-pushed the cdransf/button-high-contrast-label-fix branch from 458c8b0 to a67009e Compare September 10, 2024 14:48
@cdransf cdransf force-pushed the cdransf/button-high-contrast-label-fix branch from a67009e to 4841afe Compare September 10, 2024 23:36
Copy link
Collaborator

@rise-erpelding rise-erpelding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to ensure that this looks consistent in light mode as well? I'm seeing some introduced issues here that might need to be taken care of if so:

(In AssistivTunnel, with the High Contrast White theme):
image

(In Chrome, emulating forced colors and prefers-color-scheme: light):
image

@cdransf
Copy link
Member Author

cdransf commented Sep 12, 2024

Do we need to ensure that this looks consistent in light mode as well? I'm seeing some introduced issues here that might need to be taken care of if so:

(In AssistivTunnel, with the High Contrast White theme): image

(In Chrome, emulating forced colors and prefers-color-scheme: light): image

Do we need to ensure that this looks consistent in light mode as well? I'm seeing some introduced issues here that might need to be taken care of if so:

(In AssistivTunnel, with the High Contrast White theme): image

(In Chrome, emulating forced colors and prefers-color-scheme: light): image

✨ Huh — it looks like the button-content-color tokens are getting set in the button's index.css file but not defined. Setting them on .spectrum-Button looks good (and they can be updated by subsequent declarations specific to different states):

.spectrum-Button {
  --highcontrast-button-content-color-default: ButtonText;
  --highcontrast-button-content-color-hover: ButtonText;
  --highcontrast-button-content-color-focus: ButtonText;
  --highcontrast-button-content-color-down: ButtonText;
}

The styles aren't terribly distinct, but I imagine the available colors don't allow them to be.

Screenshot 2024-09-12 at 4 46 58 PM Screenshot 2024-09-12 at 4 46 12 PM

Copy link
Collaborator

@rise-erpelding rise-erpelding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

Comment on lines 343 to 355
&.spectrum-Button--negative .spectrum-Button-label {
forced-color-adjust: none;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be applied to.spectrum-Button-label on all the buttons, not just the negative variant? I see it's already applied above to the accent variant, and I am seeing the black text backplate on the primary variant:
Screenshot 2024-09-13 at 10 33 08 AM

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--highcontrast-button-content-color-default: ButtonText;
--highcontrast-button-content-color-hover: ButtonText;
--highcontrast-button-content-color-focus: ButtonText;
--highcontrast-button-content-color-down: ButtonText;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition, I think it would be a good idea to be explicit about setting the matching background color too. Right now we're relying on the default.

--highcontrast-button-background-color-default: ButtonFace;
--highcontrast-button-background-color-hover: ButtonFace;
--highcontrast-button-background-color-down: ButtonFace;
--highcontrast-button-background-color-focus: ButtonFace;
--highcontrast-button-background-color-disabled: ButtonFace;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -306,6 +306,10 @@ a.spectrum-Button {
/* Windows High Contrast Mode */
@media (forced-colors: active) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we're cleaning up these high contrast styles, could you bring over some of the changes I made in the spectrum 2 migration here? The use of the Highlight background should be paired with HighlightText: 597d33f

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if this lines up with what you're expecting 853ddac#diff-97b5a7e747486aca74b3076354c28a00ef69dab3c91dc0806d926078198571a2R335

Thanks for taking a look! 🙂

Copy link
Collaborator

@jawinn jawinn Sep 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Could you keep the &.spectrum-Button--accent.spectrum-Button--fill selector the same for now? Removing the fill class hasn't been done yet in S1, so keeping that the same should avoid needing changes on the SWC side.
Also, really minor but it looks like the indentation needs an update there.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! Just reverted that.

@cdransf cdransf force-pushed the cdransf/button-high-contrast-label-fix branch 5 times, most recently from eac62c6 to dfa160a Compare September 13, 2024 16:33
@cdransf cdransf enabled auto-merge (squash) September 13, 2024 16:44
@cdransf cdransf requested a review from jawinn September 13, 2024 17:48
@cdransf cdransf force-pushed the cdransf/button-high-contrast-label-fix branch from dfa160a to 32ccd99 Compare September 13, 2024 17:48
Copy link
Collaborator

@jawinn jawinn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those changes look good, thanks.

One last issue I am seeing is related to the border colors. I saw they were changing on hover of the outline variants in WHCM, but not the others. And the border colors should be the same as the background for the accent hover/focus/active.

I think adding something like this to the forced-colors styles should work? (not tested):

.spectrum-Button {
    --highcontrast-button-border-color-default: ButtonBorder;
    --highcontrast-button-border-color-hover: ButtonBorder;
    --highcontrast-button-border-color-focus: ButtonBorder;
    --highcontrast-button-border-color-down: ButtonBorder;

    --mod-button-animation-duration: 0s;

    &.spectrum-Button--accent.spectrum-Button--fill {
        --highcontrast-button-border-color-default: ButtonText;
        --highcontrast-button-border-color-hover: Highlight;
        --highcontrast-button-border-color-focus: Highlight;
        --highcontrast-button-border-color-down: Highlight;
    }
}

I also got rid of the transition duration here since the system colors don't seem to transition and look quite strange while changing on hover/focus.

I'm a little unclear about what the hover colors should be, while ensuring contrast, given that originally it looks like the design intention was to change the border color on hover.

Comment on lines 344 to 345
--highcontrast-button-content-color-down: HighlightText;
--highcontrast-button-content-color-focus: HighlightText;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These just need the indentation adjusted.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing these on WHCM and they behave as I believe we're expecting. The outline variation border no longer transitions on hover.

I'm curious about the intent as well — outside of WHCM there's a subtle darkening of the whole outlined button, but that isn't going to work in high contrast mode.

I'm going to push up a change that includes the four property definitions added to .spectrum-Button, the added mod (spacing included so we've got a distinction between the core properties and mods) and the updated .spectrum-Button--accent.spectrum-Button--fill definitions.

@cdransf cdransf force-pushed the cdransf/button-high-contrast-label-fix branch from e0e3f3f to c96ae2b Compare September 13, 2024 21:02
@cdransf cdransf closed this Sep 13, 2024
auto-merge was automatically disabled September 13, 2024 21:45

Pull request was closed

@cdransf cdransf reopened this Sep 13, 2024
@cdransf cdransf force-pushed the cdransf/button-high-contrast-label-fix branch from c96ae2b to 135d345 Compare September 16, 2024 16:09
@cdransf cdransf requested a review from jawinn September 16, 2024 16:09
@cdransf cdransf force-pushed the cdransf/button-high-contrast-label-fix branch from 135d345 to 280cab2 Compare September 16, 2024 20:54
.changeset/little-cows-hang.md Outdated Show resolved Hide resolved
components/button/index.css Show resolved Hide resolved
components/button/index.css Outdated Show resolved Hide resolved
@cdransf cdransf requested a review from jawinn September 16, 2024 23:03
@cdransf cdransf force-pushed the cdransf/button-high-contrast-label-fix branch from 5d4054e to ec2fb49 Compare September 17, 2024 13:28
@cdransf cdransf force-pushed the cdransf/button-high-contrast-label-fix branch from af1d020 to 4dc7f9e Compare September 17, 2024 15:14
@cdransf cdransf merged commit 06491f3 into main Sep 17, 2024
14 checks passed
@cdransf cdransf deleted the cdransf/button-high-contrast-label-fix branch September 17, 2024 15:31
@github-actions github-actions bot mentioned this pull request Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-review run_vrt For use on PRs looking to kick off VRT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants